package stw.brassdawn.resource;

import java.util.HashMap;

import stw.brassdawn.entity.Entity;

public class EntityLibrary {
	private static EntityLibrary myLibrary = null;
	private HashMap<Integer, Entity> myEntities = null;
	
	private EntityLibrary( ) {
		myEntities = new HashMap<Integer, Entity>();
	}
	
	public static EntityLibrary getEntityLibrary( ) {
		if( myLibrary == null ) {
			myLibrary = new EntityLibrary( );
		}
		
		return myLibrary;
	}
	
	public void setEntity( Entity e ) {
		Integer key = new Integer(e.getUnitID());
		if( !myEntities.containsKey(key) ) {
			myEntities.put( key, e );
		}
	}
	
	public Entity getEntity( int id ) {
		Integer key = new Integer( id );
		Entity rv = null;
		if( myEntities.containsKey(key)) {
			rv = myEntities.get(key);
		}
		return rv;
	}
}
